/*
 * Classname MultipleInstance.java
 * 
 * Version Information
 * Date Mar 27, 2006
 *
 * Copyright (c) AmSoft Systems, 2006
 */
package net.amsoft.iservice.isso.service.test;

import java.util.ArrayList;

import net.amsoft.iservice.isso.hibernate.tests.IBrokerTest;
import net.amsoft.iservice.isso.service.ISSOService;
import net.amsoft.iservice.util.exception.IServiceException;
import net.amsoft.iservice.util.exception.IServiceSystemException;

/**
 * @author jyoti
 * 
 * TODO To change the template for this generated type comment go to Window -
 * Preferences - Java - Code Style - Code Templates
 */
public class MultipleInstance
{
    private static String sIBrokerName = "isso.ibroker0.amsoft.co.in";
    private static String sPassword = "password";

    public static final void testSubscribe(String sGlobalInumber,
            ArrayList asSynonyms, String sActivationToken,String sEmailAddress) {
        System.out
                .println("SUBSCRIBE---------------------------------------------------------------");

        /*
         * Create,, initalize arraylist of Synonyms
         */

        try {
            ISSOService.subscribe(sGlobalInumber, sIBrokerName, asSynonyms,
                    sActivationToken,sEmailAddress);

        } catch (Exception e) {
            System.out.println("subscribe() does not work correctly");
            e.printStackTrace();
            if (e instanceof IServiceSystemException) {
                System.out
                        .println("+++++++++++++++++++++++++++++++++++++++++++++++++");
                System.out.println(e.getMessage());

            }
        }
        //debug();

    }

    /**
     * @throws IServiceException
     *  
     */
    private static void activateUpdatePrincipal(String sGlobalInumber)
            throws IServiceException {
        try {
            ISSOService.activateUpdatePrincipal(sGlobalInumber, "Jyoti",
                    "Arora", "greering", "jyoti@amsot.net", sPassword, 1,
                    "Jyoti");
        } catch (Exception e) {

        }

    }

    private static void updateSynonyms(String sGlobalInumber, ArrayList asAdd,
            boolean bAdd) {
        try {

            if (bAdd)
                ISSOService.updateSynonyms(sGlobalInumber, asAdd, true);
            else
                ISSOService.updateSynonyms(sGlobalInumber, asAdd, false);
        } catch (Exception e) {

            e.printStackTrace();
        }
    }

    public static void main(String[] args) throws IServiceException,
            InterruptedException {

        IBrokerTest iBT = new IBrokerTest();
        IBrokerTest.mB();

        String sGlobalInumber = "Multiple1";
        ArrayList al = new ArrayList();
        testSubscribe(sGlobalInumber, al, "Activation1","emailAddress");

        activateUpdatePrincipal(sGlobalInumber);

        Thread.sleep(30000);
        ArrayList al1 = new ArrayList();
        al1.add("Synonymj1");
        updateSynonyms(sGlobalInumber, al1, false);

    }
}